<div class="row">
  <div class="col-lg-12">
    <h1 class="page-header">房源数据</h1>
  </div>
</div>

<div class="panel panel-default">
  <div class="panel-heading">
    <text class="panel-title">汇总数据</text>
    <div id="progress" class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width:0%;color:#FFFFFF;font-weight:bold">
			0%
	  </div>
    <div class="pull-right">
     
      <%#= link_to "删除无坐标数据", filter_houses_path, class: "btn btn-danger btn-xs", style: "margin-right:5px;" %>
      <%= form_tag export_houses_path(:format => :xls), :method => :get, class: "pull-right", style: "margin-right:5px;" do %>
          <%= hidden_field_tag :query, params[:query] %>
          <%= button_tag(type: "submit", class: "btn btn-success btn-xs") do %>
              <span class="glyphicon glyphicon-floppy-save" ></span> 导出
          <% end %>
      <% end %>

      <%#= form_tag export_buses_path(:format => :csv), :method => :get, class: "pull-right", style: "margin-right:5px;" do %>
      <%#= button_tag(type: "submit", class: "btn btn-success btn-xs") do %>
      <!--<span class="glyphicon glyphicon-floppy-save"></span> 导出公交数据-->
      <%# end %>
      <%# end %>


    </div>
  </div>
  <div class="panel-body" style="min-height:750px">

    <% unless params[:query].blank? %>
        <div class="row">
          <div class="col-sm-12">
            <text class="text-danger">搜索结果显示:
              <mark><%= params[:query] %></mark>
            </text>
          </div>
        </div>
        <hr>
    <% end %>

    <table class="table table-responsive table-condensed table-hover">
      <thead>
      <tr>
        <th>ID</th>
        <th>小区名</th>
        <!--<th>街道</th>-->
        <th>建造时间</th>
        <th>楼层</th>
        <th>面积</th>
        <th>房型</th>
        <!--<th>经度</th>-->
        <!--<th>纬度</th>-->
        <th>医院</th>
        <th>公交</th>
        <th>商场</th>
        <th>地铁</th>
        <th>学校</th>
        <th>写字楼</th>
        <th>每平米价格</th>

      </tr>
      </thead>
      <tbody>
      <% @houses.each do |house| %>
          <tr>
            <td>
              <text style="font-size: small"><%= house.id %></text>
            </td>
            <td>
              <text style="font-size: small"><%= link_to "#{house.community}", house_path(house), method: :get %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.build_time %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.floor %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.area %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.room_shape %></text>
            </td>
            <!--<td>-->
            <!--<text style="font-size: small"><%#= house.latitude %></text>-->
            <!--</td>-->
            <!--<td>-->
            <!--<text style="font-size: small"><%#= house.longitude %></text>-->
            <!--</td>-->
            <td>
              <text style="font-size: small"><%= house.hospitals.length %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.buses.length %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.shops.length %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.subways.length %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.schools.length %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.works.length %></text>
            </td>
            <td>
              <text style="font-size: small"><%= house.average_price %></text>
            </td>

          </tr>
      <% end %>


      </tbody>
    </table>

    <%= will_paginate @houses, :param_name => 'page',
                      :previous_label => t("前一页"), :next_label => t("后一页"), :inner_window => 1 %>

  </div>
</div>


<script type="text/javascript">
  function displayExcelData(data) {
      var per_progress=(data.id*100/3000).toFixed(1)
      $('#progress').html(per_progress+"%");
      if(data.id>30){
        $("#progress").css('width',per_progress+"%"); 
      }       
  }



  function demo(){
    console.log("fjdskl");
  }
</script>
